package info.ask4research.model.roles;

import info.ask4research.model.UnitOfLearning;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;

@JsonAutoDetect
@Entity
@Table(name="Role")
public class Role {


	@Id
	@GeneratedValue
	@Column(name="role_ID")
	private int id;
	@Column(name="text", nullable=false)
	@JsonProperty
	private String text;
	@ManyToOne(cascade = CascadeType.ALL)
	@JsonIgnore
	private UnitOfLearning unitOfLearning;
	@Column(name="staffRole", nullable=false)
	private boolean staffRole;
	@Column(name="learnerRole", nullable=false)
	private boolean learnerRole;
	@Transient
	private boolean leaf = true;
	@Transient
	private String cls = "file";
	@Column(name="minPersons", nullable=true)
	@JsonProperty
	private int minPersons;
	@Column(name="maxPersons", nullable=true)
	@JsonProperty
	private int maxPersons;
	@Column(name="information", nullable=true)
	@Lob
	@JsonProperty
	private String information;
	@Column(name="allowCreation")
	@JsonProperty
	private boolean allowCreation;
	@Column(name="notAssignToOther")
	@JsonProperty
	private boolean notAssignToOther;
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public UnitOfLearning getUnitOfLearning() {
		return unitOfLearning;
	}
	public void setUnitOfLearning(UnitOfLearning unitOfLearning) {
		this.unitOfLearning = unitOfLearning;
	}
	public boolean isStaffRole() {
		return staffRole;
	}
	public void setStaffRole(boolean staffRole) {
		this.staffRole = staffRole;
	}
	public boolean isLearnerRole() {
		return learnerRole;
	}
	public void setLearnerRole(boolean learnerRole) {
		this.learnerRole = learnerRole;
	}
	public boolean isLeaf() {
		return true;
	}
	public void setLeaf(boolean leaf) {
		this.leaf = leaf;
	}
	public String getCls() {
		return cls;
	}
	public void setCls(String cls) {
		this.cls = cls;
	}
	public String getText() {
		return text;
	}
	public void setText(String text) {
		this.text = text;
	}
	public int getMinPersons() {
		return minPersons;
	}
	public void setMinPersons(int minPersons) {
		this.minPersons = minPersons;
	}
	public int getMaxPersons() {
		return maxPersons;
	}
	public void setMaxPersons(int maxPersons) {
		this.maxPersons = maxPersons;
	}
	public String getInformation() {
		return information;
	}
	public void setInformation(String information) {
		this.information = information;
	}
	public boolean isAllowCreation() {
		return allowCreation;
	}
	public void setAllowCreation(boolean allowCreation) {
		this.allowCreation = allowCreation;
	}
	public boolean isNotAssignToOther() {
		return notAssignToOther;
	}
	public void setNotAssignToOther(boolean notAssignToOther) {
		this.notAssignToOther = notAssignToOther;
	}
}
